package com.sinosoft.emplmis.collect.web;

import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.sinosoft.emplmis.collect.entity.LaborCollectEntity;
import com.sinosoft.emplmis.collect.entity.UnemployedCollectEntity;
import com.sinosoft.emplmis.collect.service.JoblessCollectService;
import com.sinosoft.emplmis.collect.service.LaborCollectService;
import com.sinosoft.framework.dict.service.DictService;

/**
 * 汇总统计导出
 * @author liux
 */
@Controller
@RequestMapping("collect/excel")
public class CollectExcelController {

	@Autowired
	private JoblessCollectService joblessCollectService;
	
	@Autowired
	private LaborCollectService laborCollectService;
	
	/**
	 * 字典服务
	 */
	@Autowired
	private DictService dictService;
	/**
	 * 失业人员全区汇总信息excel导出
	 * @return
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping("/exportUnemployedCollectList")
	@ResponseBody
	public String exportUnemployedCollectList(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException{
		
		request.setCharacterEncoding("UTF-8");//设置request的编码方式，防止中文乱码
        String fileName ="西城区失业人员情况汇总表（全区）.xls";//设置导出的文件名称
        String recommendedName = new String(fileName.getBytes(),"iso_8859_1");
        String contentType = "application/vnd.ms-excel";
        List<UnemployedCollectEntity> resultList = joblessCollectService.getJoblessCollectList();
     // 第一步，创建一个webbook，对应一个Excel文件  
        HSSFWorkbook wb = new HSSFWorkbook();  
        // 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet  
        HSSFSheet sheet = wb.createSheet(fileName);  
        // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short  
        HSSFRow row = sheet.createRow((int) 0);  
        // 第四步，创建单元格，并设置值表头 设置表头居中  
        HSSFCellStyle style = wb.createCellStyle();  
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式  
        HSSFCell cell = row.createCell(0);  
        cell.setCellValue("街道名称");  
        cell.setCellStyle(style);  
      
        cell = row.createCell(1);  
        cell.setCellValue("项目");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(2);  
        cell.setCellValue("小计");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(3);  
        cell.setCellValue("上年结转");  
        cell.setCellStyle(style);
        
        cell = row.createCell(4);  
        cell.setCellValue("本年增加-小计");  
        cell.setCellStyle(style);
        
        cell = row.createCell(5);  
        cell.setCellValue("本年增加-本月新增");  
        cell.setCellStyle(style);

        cell = row.createCell(6);  
        cell.setCellValue("个人原因减少-小计");  
        cell.setCellStyle(style);
        
        cell = row.createCell(7);  
        cell.setCellValue("个人原因减少-因客观原因");  
        cell.setCellStyle(style);
        
        cell = row.createCell(8);  
        cell.setCellValue("个人原因减少-放弃求职");  
        cell.setCellStyle(style);
        
        cell = row.createCell(9);  
        cell.setCellValue("当年实现就业人数");  
        cell.setCellStyle(style);
        
        cell = row.createCell(10);  
        cell.setCellValue("就业率");  
        cell.setCellStyle(style);
        
        if(resultList.size() > 0){
			for(int i = 0; i < resultList.size(); i++){
				row = sheet.createRow((int) i + 1); 
				UnemployedCollectEntity infoData = resultList.get(i);
				row.createCell(0).setCellValue(infoData.getStreetName());
				row.createCell(1).setCellValue(infoData.getProject());
				row.createCell(2).setCellValue(infoData.getUnemployed());
				row.createCell(3).setCellValue(infoData.getPriorYear());
				row.createCell(4).setCellValue(infoData.getTotalYear());
				row.createCell(5).setCellValue(infoData.getTotalMonth());
				row.createCell(6).setCellValue(infoData.getReduceSummary());
				row.createCell(7).setCellValue(infoData.getObjReason());
				row.createCell(8).setCellValue(infoData.getGiveupJob());
				row.createCell(9).setCellValue(infoData.getYearRealize());
				row.createCell(10).setCellValue(infoData.getEmploymentRate());
			}
				
			}
			 try  
		        {  
		        	response.setContentType(contentType);
		        	response.setHeader("Content-Disposition", "attachment; filename="+recommendedName);//
		        	OutputStream outputStream = response.getOutputStream();
		            wb.write(outputStream);  
		            outputStream.close();  
		        }  
		        catch (Exception e)  
		        {  
		            e.printStackTrace();  
		        }
		return null;
	}
	
	/**
	 * 失业人员街道汇总信息excel导出
	 * @param request
	 * @param response
	 * @return
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping("/exportUnemployedStreetList")
	@ResponseBody
	public String exportUnemployedStreetList(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException{
		request.setCharacterEncoding("UTF-8");//设置request的编码方式，防止中文乱码
        String fileName ="西城区失业人员情况汇总表（街道）.xls";//设置导出的文件名称
        String recommendedName = new String(fileName.getBytes(),"iso_8859_1");
        String contentType = "application/vnd.ms-excel";
//        String streetName = request.getParameter("streetName");//街道名称
        String streetName = new String((request.getParameter("streetName")).getBytes("iso_8859_1"),"UTF-8");
        String streetId = request.getParameter("streetId");
        List<UnemployedCollectEntity> resultList = joblessCollectService.getJoblessStreetList(streetName,streetId);
     // 第一步，创建一个webbook，对应一个Excel文件  
        HSSFWorkbook wb = new HSSFWorkbook();  
        // 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet  
        HSSFSheet sheet = wb.createSheet(fileName);  
        // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short  
        HSSFRow row = sheet.createRow((int) 0);  
        // 第四步，创建单元格，并设置值表头 设置表头居中  
        HSSFCellStyle style = wb.createCellStyle();  
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式  
        HSSFCell cell = row.createCell(0);  
        cell.setCellValue("社区名称");  
        cell.setCellStyle(style);  
      
        cell = row.createCell(1);  
        cell.setCellValue("项目");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(2);  
        cell.setCellValue("小计");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(3);  
        cell.setCellValue("上年结转");  
        cell.setCellStyle(style);
        
        cell = row.createCell(4);  
        cell.setCellValue("本年增加-小计");  
        cell.setCellStyle(style);
        
        cell = row.createCell(5);  
        cell.setCellValue("本年增加-本月新增");  
        cell.setCellStyle(style);

        cell = row.createCell(6);  
        cell.setCellValue("个人原因减少-小计");  
        cell.setCellStyle(style);
        
        cell = row.createCell(7);  
        cell.setCellValue("个人原因减少-因客观原因");  
        cell.setCellStyle(style);
        
        cell = row.createCell(8);  
        cell.setCellValue("个人原因减少-放弃求职");  
        cell.setCellStyle(style);
        
        cell = row.createCell(9);  
        cell.setCellValue("当年实现就业人数");  
        cell.setCellStyle(style);
        
        cell = row.createCell(10);  
        cell.setCellValue("就业率");  
        cell.setCellStyle(style);
        
        if(resultList.size() > 0){
			for(int i = 0; i < resultList.size(); i++){
				row = sheet.createRow((int) i + 1); 
				UnemployedCollectEntity infoData = resultList.get(i);
				row.createCell(0).setCellValue(infoData.getCommunityName());
				row.createCell(1).setCellValue(infoData.getProject());
				row.createCell(2).setCellValue(infoData.getUnemployed());
				row.createCell(3).setCellValue(infoData.getPriorYear());
				row.createCell(4).setCellValue(infoData.getTotalYear());
				row.createCell(5).setCellValue(infoData.getTotalMonth());
				row.createCell(6).setCellValue(infoData.getReduceSummary());
				row.createCell(7).setCellValue(infoData.getObjReason());
				row.createCell(8).setCellValue(infoData.getGiveupJob());
				row.createCell(9).setCellValue(infoData.getYearRealize());
				row.createCell(10).setCellValue(infoData.getEmploymentRate());
			}
				
			}
			 try  
		        {  
		        	response.setContentType(contentType);
		        	response.setHeader("Content-Disposition", "attachment; filename="+recommendedName);//
		        	OutputStream outputStream = response.getOutputStream();
		            wb.write(outputStream);  
		            outputStream.close();  
		        }  
		        catch (Exception e)  
		        {  
		            e.printStackTrace();  
		        }
		return null;
	}
	
	/**
	 * 失业人员社区汇总信息excel导出
	 * @param request
	 * @param response
	 * @return
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping("/exportUnemployedCommunityList")
	@ResponseBody
	public String exportUnemployedCommunityList(String communityName,HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException{
		request.setCharacterEncoding("UTF-8");//设置request的编码方式，防止中文乱码
        String fileName ="西城区失业人员情况汇总表（社区）.xls";//设置导出的文件名称
        String recommendedName = new String(fileName.getBytes(),"iso_8859_1");
        String contentType = "application/vnd.ms-excel";
//        String communityName = request.getParameter("communityName");//社区名称
        communityName = new String(communityName.getBytes("iso_8859_1"),"UTF-8");
        List<UnemployedCollectEntity> resultList = joblessCollectService.getJoblessCommunityList(communityName);
     // 第一步，创建一个webbook，对应一个Excel文件  
        HSSFWorkbook wb = new HSSFWorkbook();  
        // 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet  
        HSSFSheet sheet = wb.createSheet(fileName);  
        // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short  
        HSSFRow row = sheet.createRow((int) 0);  
        // 第四步，创建单元格，并设置值表头 设置表头居中  
        HSSFCellStyle style = wb.createCellStyle();  
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式  
        HSSFCell cell = row.createCell(0);  
        cell.setCellValue("社区名称");  
        cell.setCellStyle(style);  
      
        cell = row.createCell(1);  
        cell.setCellValue("项目");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(2);  
        cell.setCellValue("小计");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(3);  
        cell.setCellValue("上年结转");  
        cell.setCellStyle(style);
        
        cell = row.createCell(4);  
        cell.setCellValue("本年增加-小计");  
        cell.setCellStyle(style);
        
        cell = row.createCell(5);  
        cell.setCellValue("本年增加-本月新增");  
        cell.setCellStyle(style);

        cell = row.createCell(6);  
        cell.setCellValue("个人原因减少-小计");  
        cell.setCellStyle(style);
        
        cell = row.createCell(7);  
        cell.setCellValue("个人原因减少-因客观原因");  
        cell.setCellStyle(style);
        
        cell = row.createCell(8);  
        cell.setCellValue("个人原因减少-放弃求职");  
        cell.setCellStyle(style);
        
        cell = row.createCell(9);  
        cell.setCellValue("当年实现就业人数");  
        cell.setCellStyle(style);
        
        cell = row.createCell(10);  
        cell.setCellValue("就业率");  
        cell.setCellStyle(style);
        
        if(resultList.size() > 0){
			for(int i = 0; i < resultList.size(); i++){
				row = sheet.createRow((int) i + 1); 
				UnemployedCollectEntity infoData = resultList.get(i);
				row.createCell(0).setCellValue(infoData.getCommunityName());
				row.createCell(1).setCellValue(infoData.getProject());
				row.createCell(2).setCellValue(infoData.getUnemployed());
				row.createCell(3).setCellValue(infoData.getPriorYear());
				row.createCell(4).setCellValue(infoData.getTotalYear());
				row.createCell(5).setCellValue(infoData.getTotalMonth());
				row.createCell(6).setCellValue(infoData.getReduceSummary());
				row.createCell(7).setCellValue(infoData.getObjReason());
				row.createCell(8).setCellValue(infoData.getGiveupJob());
				row.createCell(9).setCellValue(infoData.getYearRealize());
				row.createCell(10).setCellValue(infoData.getEmploymentRate());
			}
				
			}
			 try  
		        {  
		        	response.setContentType(contentType);
		        	response.setHeader("Content-Disposition", "attachment; filename="+recommendedName);//
		        	OutputStream outputStream = response.getOutputStream();
		            wb.write(outputStream);  
		            outputStream.close();  
		        }  
		        catch (Exception e)  
		        {  
		            e.printStackTrace();  
		        }
		return null;
	}
	
	/*
	 * 导出全区劳动力汇总信息
	 */
	@RequestMapping(value="/exportLaborCollect")
	@ResponseBody
	public ModelAndView exportLaborCollect(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException{
		
		request.setCharacterEncoding("UTF-8");//设置request的编码方式，防止中文乱码
        String fileName ="西城区劳动力就业情况汇总表（全区）.xls";//设置导出的文件名称
        String recommendedName = new String(fileName.getBytes(),"iso_8859_1");
        String contentType = "application/vnd.ms-excel";
		List<LaborCollectEntity> laborCollectEntityList = laborCollectService.getLaborCollectList();
		// 第一步，创建一个webbook，对应一个Excel文件  
        HSSFWorkbook wb = new HSSFWorkbook();  
        // 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet  
        HSSFSheet sheet = wb.createSheet(fileName);  
        // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short  
        HSSFRow row = sheet.createRow((int) 0);  
        // 第四步，创建单元格，并设置值表头 设置表头居中  
        HSSFCellStyle style = wb.createCellStyle();  
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式  

        HSSFCell cell = row.createCell(0);  
        cell.setCellValue("街道名称");  
        cell.setCellStyle(style);  
      
        cell = row.createCell(1);  
        cell.setCellValue("户籍劳动年龄内人口总数");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(2);  
        cell.setCellValue("小计");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(3);  
        cell.setCellValue("单位就业");  
        cell.setCellStyle(style);
        
        cell = row.createCell(4);  
        cell.setCellValue("灵活就业");  
        cell.setCellStyle(style);       
        
        cell = row.createCell(5);  
        cell.setCellValue("自主创业");  
        cell.setCellStyle(style);

        cell = row.createCell(6);  
        cell.setCellValue("个体经营");  
        cell.setCellStyle(style);
        
        cell = row.createCell(7);  
        cell.setCellValue("无业求职人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(8);  
        cell.setCellValue("无就业愿望人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(9);  
        cell.setCellValue("失联人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(10);  
        cell.setCellValue("就业率");  
        cell.setCellStyle(style);
        
        cell = row.createCell(11);  
        cell.setCellValue("单位就业率");  
        cell.setCellStyle(style);
        
		if(laborCollectEntityList.size() > 0){
			for(int i = 0; i < laborCollectEntityList.size(); i++){
				row = sheet.createRow((int) i + 1); 
				LaborCollectEntity laborCollect = laborCollectEntityList.get(i);
				//街道名称
				row.createCell(0).setCellValue(laborCollect.getStreetName());
				//户籍劳动年龄内人口总数
				row.createCell(1).setCellValue(laborCollect.getLaborNumInAge());
				//小计
				row.createCell(2).setCellValue(laborCollect.getSubTotal());
				//单位就业
				row.createCell(3).setCellValue(laborCollect.getCompany());
				//灵活就业
				row.createCell(4).setCellValue(laborCollect.getFlexibleEmployed());
				//自主创业
				row.createCell(5).setCellValue(laborCollect.getSelfEmployed());
				//个体经营
				row.createCell(6).setCellValue(laborCollect.getIndividualOperation());
				//无业求职人员
				row.createCell(7).setCellValue(laborCollect.getUnJobPeople());
				//无就业愿望人员
				row.createCell(8).setCellValue(laborCollect.getUndesirePeople());
				//失联人员
				row.createCell(9).setCellValue(laborCollect.getLoseTouchPeople());
				//就业率
				row.createCell(10).setCellValue(laborCollect.getEmployedRate());
				//单位就业率
				row.createCell(11).setCellValue(laborCollect.getCompanyRate());
			}
			
		}
		 try  
	        {  
			    response.setContentType(contentType);
	        	response.setHeader("Content-Disposition", "attachment; filename="+recommendedName);
	        	OutputStream outputStream = response.getOutputStream();
	            wb.write(outputStream);  
	            outputStream.close();  
	        }  
	        catch (Exception e)  
	        {  
	            e.printStackTrace();  
	        }
		return null;  
	}
	
	/*
	 * 导出街道劳动力汇总信息
	 */
	@RequestMapping(value="/exportLaborStreetCollect")
	@ResponseBody
	public ModelAndView exportLaborStreetCollect(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException{
		
		request.setCharacterEncoding("UTF-8");//设置request的编码方式，防止中文乱码
        String fileName ="西城区劳动力就业情况汇总表（街道）.xls";//设置导出的文件名称
        String recommendedName = new String(fileName.getBytes(),"iso_8859_1");
        String contentType = "application/vnd.ms-excel";
//        String streetName = request.getParameter("streetName");//街道名称
        String streetName = new String((request.getParameter("streetName")).getBytes("iso_8859_1"),"UTF-8");
        String streetId = request.getParameter("streetId");
		List<LaborCollectEntity> laborCollectEntityList = laborCollectService.getLaborStreetList(streetName,streetId);
		// 第一步，创建一个webbook，对应一个Excel文件  
        HSSFWorkbook wb = new HSSFWorkbook();  
        // 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet  
        HSSFSheet sheet = wb.createSheet(fileName);  
        // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short  
        HSSFRow row = sheet.createRow((int) 0);  
        // 第四步，创建单元格，并设置值表头 设置表头居中  
        HSSFCellStyle style = wb.createCellStyle();  
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式  

        HSSFCell cell = row.createCell(0);  
        cell.setCellValue("社区名称");  
        cell.setCellStyle(style);  
      
        cell = row.createCell(1);  
        cell.setCellValue("户籍劳动年龄内人口总数");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(2);  
        cell.setCellValue("小计");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(3);  
        cell.setCellValue("单位就业");  
        cell.setCellStyle(style);
        
        cell = row.createCell(4);  
        cell.setCellValue("灵活就业");  
        cell.setCellStyle(style);       
        
        cell = row.createCell(5);  
        cell.setCellValue("自主创业");  
        cell.setCellStyle(style);

        cell = row.createCell(6);  
        cell.setCellValue("个体经营");  
        cell.setCellStyle(style);
        
        cell = row.createCell(7);  
        cell.setCellValue("无业求职人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(8);  
        cell.setCellValue("无就业愿望人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(9);  
        cell.setCellValue("失联人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(10);  
        cell.setCellValue("就业率");  
        cell.setCellStyle(style);
        
        cell = row.createCell(11);  
        cell.setCellValue("单位就业率");  
        cell.setCellStyle(style);
        
		if(laborCollectEntityList.size() > 0){
			for(int i = 0; i < laborCollectEntityList.size(); i++){
				row = sheet.createRow((int) i + 1); 
				LaborCollectEntity laborCollect = laborCollectEntityList.get(i);
				//街道名称
				row.createCell(0).setCellValue(laborCollect.getCommunityName());
				//户籍劳动年龄内人口总数
				row.createCell(1).setCellValue(laborCollect.getLaborNumInAge());
				//小计
				row.createCell(2).setCellValue(laborCollect.getSubTotal());
				//单位就业
				row.createCell(3).setCellValue(laborCollect.getCompany());
				//灵活就业
				row.createCell(4).setCellValue(laborCollect.getFlexibleEmployed());
				//自主创业
				row.createCell(5).setCellValue(laborCollect.getSelfEmployed());
				//个体经营
				row.createCell(6).setCellValue(laborCollect.getIndividualOperation());
				//无业求职人员
				row.createCell(7).setCellValue(laborCollect.getUnJobPeople());
				//无就业愿望人员
				row.createCell(8).setCellValue(laborCollect.getUndesirePeople());
				//失联人员
				row.createCell(9).setCellValue(laborCollect.getLoseTouchPeople());
				//就业率
				row.createCell(10).setCellValue(laborCollect.getEmployedRate());
				//单位就业率
				row.createCell(11).setCellValue(laborCollect.getCompanyRate());
			}
			
		}
		 try  
	        {  
			    response.setContentType(contentType);
	        	response.setHeader("Content-Disposition", "attachment; filename="+recommendedName);
	        	OutputStream outputStream = response.getOutputStream();
	            wb.write(outputStream);  
	            outputStream.close();  
	        }  
	        catch (Exception e)  
	        {  
	            e.printStackTrace();  
	        }
		return null;  
	}
	
	/*
	 * 导出社区劳动力汇总信息
	 */
	@RequestMapping(value="/exportLaborCommunityCollect")
	@ResponseBody
	public ModelAndView exportLaborCommunityCollect(HttpServletRequest request,HttpServletResponse response,String communityName) throws UnsupportedEncodingException{
		
		request.setCharacterEncoding("UTF-8");//设置request的编码方式，防止中文乱码
        String fileName ="西城区劳动力就业情况汇总表（社区）.xls";//设置导出的文件名称
        String recommendedName = new String(fileName.getBytes(),"iso_8859_1");
        String contentType = "application/vnd.ms-excel";
        communityName = new String(communityName.getBytes("iso_8859_1"),"UTF-8");
		List<LaborCollectEntity> laborCollectEntityList = laborCollectService.getLaborCommunityList(communityName);
		// 第一步，创建一个webbook，对应一个Excel文件  
        HSSFWorkbook wb = new HSSFWorkbook();  
        // 第二步，在webbook中添加一个sheet,对应Excel文件中的sheet  
        HSSFSheet sheet = wb.createSheet(fileName);  
        // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short  
        HSSFRow row = sheet.createRow((int) 0);  
        // 第四步，创建单元格，并设置值表头 设置表头居中  
        HSSFCellStyle style = wb.createCellStyle();  
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式  

        HSSFCell cell = row.createCell(0);  
        cell.setCellValue("户籍劳动年龄内人口总数");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(1);  
        cell.setCellValue("小计");  
        cell.setCellStyle(style);  
        
        cell = row.createCell(2);  
        cell.setCellValue("单位就业");  
        cell.setCellStyle(style);
        
        cell = row.createCell(3);  
        cell.setCellValue("灵活就业");  
        cell.setCellStyle(style);       
        
        cell = row.createCell(4);  
        cell.setCellValue("自主创业");  
        cell.setCellStyle(style);

        cell = row.createCell(5);  
        cell.setCellValue("个体经营");  
        cell.setCellStyle(style);
        
        cell = row.createCell(6);  
        cell.setCellValue("无业求职人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(7);  
        cell.setCellValue("无就业愿望人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(8);  
        cell.setCellValue("失联人员");  
        cell.setCellStyle(style);
        
        cell = row.createCell(9);  
        cell.setCellValue("就业率");  
        cell.setCellStyle(style);
        
        cell = row.createCell(10);  
        cell.setCellValue("单位就业率");  
        cell.setCellStyle(style);
        
		if(laborCollectEntityList.size() > 0){
			for(int i = 0; i < laborCollectEntityList.size(); i++){
				row = sheet.createRow((int) i + 1); 
				LaborCollectEntity laborCollect = laborCollectEntityList.get(i);
				//户籍劳动年龄内人口总数
				row.createCell(0).setCellValue(laborCollect.getLaborNumInAge());
				//小计
				row.createCell(1).setCellValue(laborCollect.getSubTotal());
				//单位就业
				row.createCell(2).setCellValue(laborCollect.getCompany());
				//灵活就业
				row.createCell(3).setCellValue(laborCollect.getFlexibleEmployed());
				//自主创业
				row.createCell(4).setCellValue(laborCollect.getSelfEmployed());
				//个体经营
				row.createCell(5).setCellValue(laborCollect.getIndividualOperation());
				//无业求职人员
				row.createCell(6).setCellValue(laborCollect.getUnJobPeople());
				//无就业愿望人员
				row.createCell(7).setCellValue(laborCollect.getUndesirePeople());
				//失联人员
				row.createCell(8).setCellValue(laborCollect.getLoseTouchPeople());
				//就业率
				row.createCell(9).setCellValue(laborCollect.getEmployedRate());
				//单位就业率
				row.createCell(10).setCellValue(laborCollect.getCompanyRate());
			}
			
		}
		 try  
	        {  
			    response.setContentType(contentType);
	        	response.setHeader("Content-Disposition", "attachment; filename="+recommendedName);
	        	OutputStream outputStream = response.getOutputStream();
	            wb.write(outputStream);  
	            outputStream.close();  
	        }  
	        catch (Exception e)  
	        {  
	            e.printStackTrace();  
	        }
		return null;  
	}
	
}
